feat(transform): echo reasoning_content for DeepSeek thinking mode#21
Merged
Conversation
DeepSeek thinking-capable models (including those served via OpenAI-compatible aggregators like OpenRouter, SiliconFlow, and Fireworks) reject follow-up turns with a 400 when assistant messages omit reasoning_content. To fix this: - Add requiresReasoningEcho to detect DeepSeek by provider ID or model name - Inject a placeholder reasoning_content on assistant messages lacking real reasoning during request rendering for reasoning-mode providers - Surface structured thinking as reasoning_content in rendered responses so clients can replay it on subsequent turns - Add tests covering reasoning rendering and injection behavior Messages carrying genuine reasoning are left untouched to preserve the real chain-of-thought.
Update DeepSeek catalog rates and model pricing. Add DeepSeek v4 capabilities and lookup/pricing tests.
DeepSeek requires reasoning_content on all assistant turns, while Kimi models only need it on turns carrying tool_calls. Replace the boolean injection flag with a reasoningScope enum (none/all/toolCalls) so each provider gets the correct behavior. Extract isDeepSeekTarget to gate DeepSeek-specific fixes separately from reasoning echo detection.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
reasoning_contentin OpenAI-compatible responsesreasoning_contentfor DeepSeek follow-up assistant messages that lack real reasoningTests
cd backend && go test ./internal/transform